<template>
	<view class="content">
		<view class="jyclass m-t">
			<view class="uni-list">
				<view class="uni-list-cell" >
					<view class="uni-media-list">
						<view class="uni-media-list-logo">
							<image :src="order.nav_list_logo" mode="aspectFill"></image>
						</view>
						<view class="uni-media-list-body">
							<view class="uni-media-list-text-top uni-ellipsis">{{order.nav_name || ''}}</view>
							<view class="uni-media-list-text-bottom ">从0基础到一线大型互联网公司流行框架，豪华讲师团手</view>
							<view class="price">￥{{order.paymoney || '0.00'}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="yt-list bor10">
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">课程总金额</text>
				<text class="cell-tip">￥{{order.money|| '0.00'}}</text>
			</view>
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">优惠折扣</text>
				<text class="cell-tip">-￥{{yhmoney|| '0.00'}}</text>
			</view>
			<view class="yt-list-cell b-b">
				<text class="cell-tit clamp">应付</text>
				<text class="cell-tip red">￥{{order.paymoney|| '0.00'}}</text>
			</view>
		</view>
		
		<view class="page-bottom">
			<view class="price"><text class="b">￥{{order.paymoney|| '0.00'}}</text></view>
			<view class="btn" @click="submit">提交订单</view>
		</view>
	</view>
</template>
<script>
export default {
	data(){
		return {
			nav_id: '',//课程id
			order: {},
			
		}
		
	},
	onLoad(option) {
		if(option && option.id){
			
			this.nav_id = option.id;
			this.loadData();
		}
	},
	methods:{
		async loadData(){
			
			await this.$http.post('api/order/index',{id: this.nav_id}).then(res=>{
				if(res.code === this.sucCode){
					this.order = res.data || {};
				}else{
					this.$mHelper.toast(res.msg);
				}
				
			}).catch(err=>{
				console.log(err);
				
			})
			
		},
		async submit(){
			//api/order/addorder
			uni.showLoading({
				title:'正在处理..'
			})
			let t = this;
			await this.$http.post('api/order/addorder',{id: this.nav_id}).then(res=>{
				if(res.code === this.sucCode){
					this.$mHelper.toast('订单提交成功');
					let order_id = res.data.id;
					setTimeout(function(){
						uni.hideLoading();
						t.$mHelper.navTo('/pages/order/pay','push',{id:order_id,money:t.order.paymoney});
					},1000);
				}else{
					this.$mHelper.toast(res.msg);
					uni.hideLoading();
				}
				
			}).catch(err=>{
				console.log(err);
				uni.hideLoading();
			})
			
		},
		navToDetailPage(item,url) {
			uni.navigateTo({
				url: url
			})
		},
	}	
}
</script>
<style lang="scss">
	page{overflow: hidden;}
	.yt-list {
		background: #fff;
	}
	.yt-list-cell {
		display: flex;
		align-items: center;
		padding: 10upx 30upx 10upx 40upx;
		line-height: 70upx;
		position: relative;
	
		&.cell-hover {
			background: #fafafa;
		}
	
		&.b-b:after {
			left: 30upx;
		}
		.cell-tit {
			flex: 1;
			font-size: 26upx;
			color: $font-color-light;
			margin-right: 10upx;
		}
		.cell-tip {
			font-size: 26upx;
			color: $font-color-dark;
	
			&.red{
				color: #ff0000;font-size: 36upx;
			}
		}
	}
	.page-bottom .price{right:auto;left:20upx}
</style>
